<template>
    <div>
        <h1>登录</h1>
        <table class="table">
            <tr>
                <td>房态编号</td>
                <td>
               <input type="text" v-model="data.rid">
                </td>
            </tr>
            <tr>
                <td>房态名称</td>
                <td>
               <input type="text" v-model="data.name">
                </td>
            </tr>
            <tr>
                <td>房态价格</td>
                <td>
               <input type="text" v-model="data.price">
                </td>
            </tr>
            <tr>
                <td>房态数量</td>
                <td>
               <input type="text" v-model="data.num">
                </td>
            </tr>
            <tr>
                <td>房态状态</td>
                <td>
                    <input type="checkbox" v-model="data.stata">选中为开房，不选中为关房

                </td>
            </tr>
            <tr>
              
                <td class="2">
                    <input type="button" value="添加" @click="Add">
                </td>
            </tr>
        </table>
    </div>
</template>
<script setup lang="ts">
import {ref} from "vue"
import axios from "axios";
const data=ref({
    "id": 0,
  "rid": 0,
  "name": "",
  //"createTime": "2025-04-14T01:54:35.306Z",
  "price": 0,
  "num": 0,
  "stata": true
})
const Add=()=>{
    axios.post("https://localhost:7263/api/Room/AddRoom",data.value).then(res=>{
       if(res.data>0){
        alert('添加成功');
        location.href='/ShowView';
       }
       else{
        alert('添加失败');
       }
    })
}
</script>
<style scoped></style>